/*
 * ListenerNuevoCd.java
 *
 * Created on 28 de octubre de 2005, 1:22
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package fmap.gui.actionListener;

import fmap.actions.collection.searchCollection.SearchAdvancedCollectionAction;
import fmap.gui.JFrameGroupFile;
import fmap.gui.JFrameSearchAdvanced;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import fmap.model.Cat;
import fmap.model.GroupFile;
import fmap.model.SearchAdvancedModel;
import java.awt.event.ActionListener;

/**
 *
 * @author javi
 */
public class ListenerJFrameSearchAdvanced implements ActionListener
{
    JFrameSearchAdvanced jFrameSearchAdvanced;
    Cat catSelect;
    
    /** Creates a new instance of ListenerNuevoCd */
    public ListenerJFrameSearchAdvanced ( JFrameSearchAdvanced _jFrameSearchAdvanced )
    {
        jFrameSearchAdvanced = _jFrameSearchAdvanced;
    }
    
    
    public void actionPerformed (ActionEvent ae)
    {
        JButton jb = (JButton)ae.getSource ();
        
        // Insertamos una nueva categoria
        if( jb.getActionCommand ().equals ("buscar") )
        {
            
            jFrameSearchAdvanced.dispose ();
            

            GroupFile groupFile = (GroupFile)jFrameSearchAdvanced.getComboBoxGroupFileSearch ().getSelectedItem ();
            
            
            SearchAdvancedModel searchAdvancedModel = new SearchAdvancedModel (
                    jFrameSearchAdvanced.getTextFNameSearch ().getText (),
                    jFrameSearchAdvanced.getTextFDateIniSearch ().getText (),
                    jFrameSearchAdvanced.getTextFDateFinSearch ().getText (),
                    jFrameSearchAdvanced.getTextFSizeIniSearch ().getText (),
                    jFrameSearchAdvanced.getTextFSizeFinSearch ().getText (),
                    jFrameSearchAdvanced.getComboBoxTypeSizeSearch ().getSelectedItem ().toString (),
                    groupFile,
                    jFrameSearchAdvanced.getTextFWordKeySearch ().getText (),
                    jFrameSearchAdvanced.getTextFCommentSearch ().getText (),
                    jFrameSearchAdvanced.getCheckBoxCase ().isSelected ());

            
            new SearchAdvancedCollectionAction ( searchAdvancedModel );
            
            
            
            
/*
 
            if( !jFrameAdminCat.getTextFCatMapF ().getText ().trim ().equals ("") )
            {
 
                new CatDao ().insertCat ( jFrameAdminCat.getTextFCatMapF ().getText () );
 
                // Actualizamos la lista de categorias
                Vector vCats = new CatDao ().selectCats ();
                if( vCats.size () > 0 ) jFrameAdminCat.getListCatMapF ().setListData ( vCats );
                jFrameAdminCat.getTextFCatMapF ().setText ("");
            }
            else
            {
                JOptionPane.showMessageDialog (jFrameAdminCat,
                        "Debe cubrir el nombre de la categoria",
                        "ERROR",
                        JOptionPane.ERROR_MESSAGE);
            }
 */
        }
        else if ( jb.getActionCommand ().equals ("cancelar") )
        {
            jFrameSearchAdvanced.dispose ();
        }
        else if( jb.getActionCommand ().equals ("groupFile") )
        {
            new JFrameGroupFile();
        }
    }
}
